package com.bankcomm.common;

import org.keplerproject.luajava.LuaObject;

import com.bankcomm.luafuction.LuaWindow;
import com.rytong.tools.utils.Utils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * 
 * 监听点击home发出的广播
 * 
 */
public class HomeKeyEventBroadCastReceiver extends BroadcastReceiver {
	final String SYSTEM_REASON = "reason";
	final String SYSTEM_HOME_KEY = "homekey";// home key

	@Override
	public void onReceive(Context context, Intent intent) {
		try {
			String action = intent.getAction();
			if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
				String reason = intent.getStringExtra(SYSTEM_REASON);
				if (reason != null) {
					// home key处理点
					if (reason.equals(SYSTEM_HOME_KEY)) {
						if (null != Utils.keyHash_) {
							LuaObject lua = Utils.keyHash_
									.get(LuaWindow.HOMESTR);
							lua.call(null, 0);
						}

					}
				}
			}
		} catch (Exception e) {
			Utils.printException(e);
		}

	}
}